<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #cvs {
            /* 
                默认宽高 ：想要更改，要行内式设置
                width: 300px;
                height: 150px;
            */
            border: 1px solid #f00;
        }
    </style>
</head>

<body>
    <canvas id="cvs" width="2000" height="1000"></canvas>
</body>
<script>
    // 1.获取canvas的元素  
    const cvsDom = document.querySelector('#cvs')

    // 2.生成canvas绘制元素
    const context = cvsDom.getContext('2d'); 

    context.lineWidth = 3;

    context.strokeStyle = 'blue';

    context.moveTo(125, 60)

    context.lineTo(130, 70); // 起始点开始，分别加个一或者二像素就可以了

    context.closePath();   // 自动将结束点与起始位置关闭
    context.stroke();


 



</script>

</html>